package com.wanhe.vip.module.info;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.wanhe.vip.R;
import com.wanhe.vip.api.bean.VipCard;
import com.wanhe.vip.module.adapter.VipCardListAdapter;
import com.wanhe.vip.module.base.BaseDialog;

import java.util.ArrayList;

/**
 * Created by XieZaiWei on 2017/4/19.
 * 会员拥有的卡列表Dialog
 */

public class VipCardListDialog extends BaseDialog {
	private ListView lv_card;
	private VipInfoPresenter mVipInfoPresenter;
	private VipCardListAdapter mVipCardListAdapter;
	private ArrayList<VipCard> mArrCard;

	public VipCardListDialog(Context context, ArrayList<VipCard> arrCard, VipInfoPresenter vipInfoPresenter) {
		super(context);
		mArrCard = arrCard;
		mVipInfoPresenter = vipInfoPresenter;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.vip_card_list_dialog);

		lv_card = (ListView) findViewById(R.id.lv_card);

		mVipCardListAdapter = new VipCardListAdapter(getContext());

		mVipCardListAdapter.setData(mArrCard);

		lv_card.setAdapter(mVipCardListAdapter);

		lv_card.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				dismiss();
				VipCard vipCard = mArrCard.get(position);
				mVipInfoPresenter.getCardInfo(vipCard.getCardNumber(),vipCard.getBirthday() );
			}
		});

	}
}
